import { HTTP } from "../utils/http.js";

class UserModule extends HTTP {
	// 用户授权数据
	userinfo(wxInfo) {
		return this.request({
		  url: 'wxapp/userinfo',
		  method: 'POST',
		  data: {
			signature: wxInfo.signature,
			rawData: wxInfo.rawData,
			iv: wxInfo.iv,
			encryptedData: wxInfo.encryptedData
		  }
		})
  }
	
	getUserData(freeze = 0) {
		return this.request({
			url: 'wxapp/user',
			data: {
				freeze
			}
		})
	}
	// 认证
	authenticationApi(data) {
		return this.request({
			url: 'wxapp/up_auth',
			method: 'POST',
			data: {
				phone: data.phone,
				alipay_account: data.alipay_account,
				alipay_name: data.alipay_name
			}
		})
	}
	
	// 购买会员
	payVip() {
		return this.request({
			url: 'vip/pay',
			method: 'POST'
		})
	}
	// 冻结订单列表
	freezeList(page) {
		return this.request({
			url: 'user/freeze',
			data: {
				page: page + 1
			}
		})
	}
	// 体现接口
	postWithdraw(cash_fee) {
		return this.request({
			url: 'user/pay_add',
			method: 'POST',
			data: {
				cash_fee
			}
		})
	}
	// 体现明细
	withdrawList(type, page) {
		return this.request({
			url: 'user/my_detail',
			data: {
				type,
				page: page + 1
			}
		})
	}
	
	// 获取海报
	getPoster() {
		return this.request({
			url: 'user/poster'
		})
	}
	
	// 提交formid
	postFormId(formid) {
		return this.request({
			url: 'form/add',
			method: 'POST',
			data: {
				formid
			}
		})
	}
}

module.exports =  new UserModule()